package com.ft.oa.web.customer;

/**客户跟踪管理
 *
 */

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ft.oa.domain.customer.Customer;
import com.ft.oa.domain.customer.CustomerTail;
import com.ft.oa.domain.dto.ApiResult;
import com.ft.oa.domain.industrys.Industry;
import com.ft.oa.domain.sys.SysUser;
import com.ft.oa.service.customer.CustomerService;
import com.ft.oa.service.customer.CustomerTailService;
import com.ft.oa.service.industryService.IIndustryService;
import com.ft.oa.service.sys.SysUserService;
import com.ft.oa.utils.FileUtil;
import com.ft.oa.web.customer.rq.CustomerTailPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/customertail")
public class CustomerTailController {
    @Value("${file.upload.url}")
    private String uploadFilePath;
    @Autowired
    private CustomerTailService customerTailService;

    @Autowired
    private IIndustryService iIndustryService;

    @Autowired
    private CustomerService customerService;

    @Autowired
    private SysUserService sysUserService;


    /**
     * 查询客户跟踪列表
     * @param customerTailPage
     * @return
     */
    @PostMapping("/list")
    public ApiResult selectCustomerTailList(@RequestBody CustomerTailPage customerTailPage){
        IPage<CustomerTail> customerTailIPage = customerTailService.selectCustomerTail(customerTailPage);
        return ApiResult.successWithData(customerTailIPage);
    }

    /**
     * 获取行业信息
     * @return
     */
    @PostMapping("/viewhyall")
    public ApiResult viewhyall(){
        List<Industry> viewhyall = iIndustryService.viewhyall();
        return ApiResult.successWithData(viewhyall);
    }

    /**
     * 添加客户跟踪信息
     * @param customerTail
     * @return
     */
    @PostMapping("/insert")
    public ApiResult insertCustomerTail(@RequestBody CustomerTail customerTail){
        int i = customerTailService.insertCustomerTail(customerTail);
        return ApiResult.simpleSuccess();
    }

    /**
     * 调用企业名称列表
     * @return
     */
    @PostMapping("/customer")
    public ApiResult selectCustomer(){
        List<Customer> customers = customerService.selectCustomer();
        return ApiResult.successWithData(customers);
    }

    /**
     * 调用用户列表
     */
    @PostMapping("/user")
    public ApiResult selectUser(){
        List<SysUser> sysUsers = sysUserService.listAll();
        return ApiResult.successWithData(sysUsers);
    }

}
